package models

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

type DoDoctorOrderNumber struct {
	Id           int64 `json:"id"`
	DepartmentId int64 `json:"department_id"`
	CreatedAt    int64 `json:"created_at"`
}

func (a *DoDoctorOrderNumber) TableName() string {
	return DoDoctorOrderNumberTableName()
}

func DoDoctorOrderNumberTableName() string {
	return TableName("do_doctor_order_number")
}

//随医嘱生成编号
func DoDoctorOrderNumberCreate(depid int64) (*DoDoctorOrderNumber, error) {
	//获取最新一条记录
	mod := new(DoDoctorOrderNumber)
	mod.DepartmentId = depid
	mod.CreatedAt = time.Now().Unix()
	if _, err := orm.NewOrm().Insert(mod); err != nil {
		return nil, err
	}
	return mod, nil
}
